package com.example.demo.java;

import com.example.demo.utils.date.DateUtils;
import com.healthmarketscience.jackcess.*;

import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.sql.Types;

public class Mdb {

    public static void main(String[] args) {
        try {
            Database db = null;
            File file = new File("C:\\Users\\Administrator\\Desktop\\zxy.mdb");
            if (file.exists()) {
                db = DatabaseBuilder.open(file);
            } else {
                db = DatabaseBuilder.create(Database.FileFormat.V2000, new File("C:\\Users\\Administrator\\Desktop\\zxy.mdb"));
            }
            Table newTable1 = new TableBuilder("zxy11")
                    .addColumn(new ColumnBuilder("名称").setSQLType(Types.VARCHAR))
                    .addColumn(new ColumnBuilder("日期").setSQLType(Types.DATE)).toTable(db);
            newTable1.addRow("zhangxinyu", DateUtils.now());

            Table newTable2 = new TableBuilder("zxy22")
                    .addColumn(new ColumnBuilder("名称").setSQLType(Types.VARCHAR))
                    .addColumn(new ColumnBuilder("日期").setSQLType(Types.DATE)).toTable(db);
            newTable2.addRow("zhangxinyu", DateUtils.now());

        } catch (IOException | SQLException e) {
            e.printStackTrace();
        }
    }

}
